<div style="width: 100%; height: 100%; overflow-y:auto">
    <div class="step2">
        <div class="charge_item banklist">
            <select data-am-selected class="am-form-field">
            </select>
        </div>
        <div class="clue">
            单笔下限<span class="red min">10</span>，单笔上限<span class="red max">9999999</span>
        </div>

        <div class="charge_item amount">
            <input type="number" class="am-form-field" placeholder="请填写存款金额" />
        </div>

        <div class="button2 bank">
            <button type="button" class="am-btn am-btn-primary btn-save">提交</button>
        </div>
    </div>
</div>
<style type="text/css">
.step1, .step2, .step3 {
    padding: 10px;
    font-size: 0.6rem;
}
.bankinfo .clue {
    padding: 0px 15px 0px 15px;
}
.bankinfo img {
    border: 1px solid #ccc;
    border-radius: 8px;
}
.bankinfo .qrcode {
    padding: 10px 0px 10px 0px;
}
</style>

<script>
    $("#center-top .home").hide();
    $("#center-top .back").show();
    $("#center-top .menu").hide();
    $("#center-top .back2game").show();
    
    $("#clue2 #clue2_content").html("<div style='text-align:left'>为了防止掉单，请确保充值成功后，再关闭页面。</div>");
    $("#clue2").modal({
        width: 250
    });

    var banks = [];
    ME.query(function() {
        var grade = context.user.user.layer || 0;
        grade = grade + '';
        CMD.pay_uquery(function(r) {
            for (var i in r.list) {
                var data = r.list[i];
                if (data.enable != 1 || data.payType != 'wechat') continue;
                data.layer = data.layer.split(",");
                if (data.layer.indexOf(grade) == -1) continue;
                banks.push(data);
            }
            banks.sort(function(a, b) {
                return (b.sort || 0) - (a.sort || 0);
            });

            // 填充充值列表
            for (var i in banks) {
                var d = banks[i];
                var l = '<option value="__v__">__n__</option>'.replace(/__v__/, d.mchId);
                l = l.replace(/__n__/, d.name);
                $(".banklist select").append(l);
            }

            // 最高金额、最低金额
            $(".clue .min").html(getSelectBankInfo().min);
            $(".clue .max").html(getSelectBankInfo().max);
        });
    });

    $(".bank button").click(function() {
        var d = getSelectBankInfo();
        var amount = $(".amount input").val().trim();
        if (!amount) {
            alert2("请输入存款金额", true);
            return;
        }
        amount = parseInt(amount);
        if (amount < parseInt(d.min)) {
            alert2('存款金额至少' + d.min + '元', true);
            return;
        }
        if (amount > parseInt(d.max)) {
            alert2('存款金额超过' + d.max + '元', true);
            return;
        }
                
        // 提交充值
        if (d.type == 'heyifuu') {
            // 合易付
            var url = Util.genUrl({
                file: "heyifuu.html",
                key: d.key,
                amount: amount,
                payType: 5,
            });
            window.open(url);
        }

        setTimeout(function() {
            Util.jumpUrl({
                cmd: 'charge'
            });
        }, 1500);
    });

    // 取得使用的充值方式信息
    function getSelectBankInfo() {
        var v = $(".banklist select").val();
        for (var i in banks) {
            if (banks[i].mchId == v) return banks[i];
        }
    }

    // 获取充值金额
    function _getChargeAmount() {
        return $(".amount input").val().trim();
    }
</script>